﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using System.Data;
using System.Text;
using System.Xml;
using Gift.WebApp;

using Gift.DAL;
using Gift.Model;

public partial class cn_goods_list : BasePage
{
    // Fields
    protected int bid = 0;
    
    protected string categoryId = "00000000-0000-0000-0000-000000000000";
 
    protected int cid = 0;
   
    protected string dt = "image";
    protected string goodsNo = "";
    protected string kw = "";
    protected DateTime maxDate;
    protected decimal maxPrice = 999999M;
    protected DateTime minDate;
    protected decimal minPrice = 0M;
    protected string moduleSetXmlPath = "/cn/xml/module_set.xml";
    protected string order = "id";
    protected int ot = 1;
    protected int pageCount = 0;
    protected int pageIndex = 1;
    protected int pageSize = 0x20;
    protected PageList pl = new PageList();
  
    protected string price = "";
    protected string priceOrderXmlPath = "/cn/xml/price_order.xml";
    protected int sort = 0;
    protected int total = 0;
    protected string xmlPath = "/cn/xml/goods_list.xml";

    // Methods
    protected StringBuilder DisplayTypeBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["dt"] != null)
            {
                this.dt = base.Request.QueryString["dt"];
            }
            if (base.Request.QueryString["cid"] != null)
            {
                if (base.Request.QueryString["cid"].ToString().Length == 36)
                {
                    this.cid = BaseFactory.theCategory.GetModel(base.Request.QueryString["cid"].ToString()).categoryIdentity;
                }
                else
                {
                    this.cid = Convert.ToInt32(base.Request.QueryString["cid"]);
                }
            }
            if (base.Request.QueryString["bid"] != null)
            {
                this.bid = Convert.ToInt32(base.Request.QueryString["bid"]);
            }
            if (base.Request.QueryString["price"] != null)
            {
                this.price = base.Request.QueryString["price"];
            }
            if (base.Request.QueryString["sort"] != null)
            {
                this.sort = Convert.ToInt32(base.Request.QueryString["sort"]);
            }
            if (base.Request.QueryString["kw"] != null)
            {
                this.kw = base.Request.QueryString["kw"];
            }
            if ((base.Request.QueryString["minDate"] != null) && (base.Request.QueryString["maxDate"] != null))
            {
                this.minDate = Convert.ToDateTime(base.Request.QueryString["minDate"] + " 00:00:00");
                this.maxDate = Convert.ToDateTime(base.Request.QueryString["maxDate"] + " 23:23:59");
            }
            if (base.Request.QueryString["gn"] != null)
            {
                this.goodsNo = base.Request.QueryString["gn"];
            }
            builder.AppendLine("<div class=\"classbottom\">");
            builder.AppendLine("<p><strong>显示方式</strong></p>");
            builder.AppendLine("<p class=\"list_img\">" + ((this.dt == "image") ? "<span class='current'  title=\"图文方式\">图文方式</span>" : ("<a href='?dt=image" + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "' title='图文方式'>图文方式</a>")) + "</p>");
            builder.AppendLine("<p class=\"list\">" + ((this.dt == "list") ? "<span class='current' title='列表方式'>列表方式</span>" : ("<a  href='?dt=list" + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "' title='列表方式'>列表方式</a>")) + "</p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<span class=\"clear\"></span>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder GoodsAttributeBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["dt"] != null)
            {
                this.dt = base.Request.QueryString["dt"];
            }
            if (base.Request.QueryString["cid"] != null)
            {
                if (base.Request.QueryString["cid"].ToString().Length == 36)
                {
                    this.cid = BaseFactory.theCategory.GetModel(base.Request.QueryString["cid"].ToString()).categoryIdentity;
                }
                else
                {
                    this.cid = Convert.ToInt32(base.Request.QueryString["cid"]);
                }
            }
            if (base.Request.QueryString["bid"] != null)
            {
                this.bid = Convert.ToInt32(base.Request.QueryString["bid"]);
            }
            if (base.Request.QueryString["price"] != null)
            {
                this.price = base.Request.QueryString["price"];
            }
            if (base.Request.QueryString["sort"] != null)
            {
                this.sort = Convert.ToInt32(base.Request.QueryString["sort"]);
            }
            if (base.Request.QueryString["kw"] != null)
            {
                this.kw = base.Request.QueryString["kw"];
            }
            if ((base.Request.QueryString["minDate"] != null) && (base.Request.QueryString["maxDate"] != null))
            {
                this.minDate = Convert.ToDateTime(base.Request.QueryString["minDate"] + " 00:00:00");
                this.maxDate = Convert.ToDateTime(base.Request.QueryString["maxDate"] + " 23:23:59");
            }
            if (base.Request.QueryString["gn"] != null)
            {
                this.goodsNo = base.Request.QueryString["gn"];
            }
            DataTable brandByCategoryIdentity = new DataTable();
            if (base.Request.QueryString["cid"] != null)
            {
                brandByCategoryIdentity = BaseFactory.theBrand.GetBrandByCategoryIdentity(this.cid);
            }
            else
            {
                brandByCategoryIdentity = BaseFactory.theBrand.GetBrandByCompanyId(base.CompanyId);
            }
            builder.AppendLine("<div class=\"classlist\">");
            builder.AppendLine("<ul>");
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.moduleSetXmlPath));
            builder.AppendLine("<li " + ((this.bid != 0) ? "class=\"hoverli\"" : "") + "><strong>" + (document.SelectSingleNode("set/goods_brand_screening") as XmlElement).GetAttribute("title") + "</strong>");
            builder.AppendLine("<a " + ((this.bid == 0) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">不限</a>");
            foreach (DataRow row in brandByCategoryIdentity.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<a ", (this.bid == Convert.ToInt32(row["id"])) ? "class=\"hovera\"" : "", " href=\"?dt=", this.dt, (this.cid == 0) ? "" : ("&cid=" + this.cid + ""), "&bid=", row["id"], (this.price == "") ? "" : ("&price=" + this.price + ""), (this.sort == 0) ? "" : ("&sort=" + this.sort + ""), (this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw)), (base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "", (base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "", (this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "", "\">", row["brandName"], "</a>" }));
            }
            builder.AppendLine("</li>");
            XmlDocument document2 = new XmlDocument();
            document2.Load(base.Server.MapPath(this.priceOrderXmlPath));
            XmlNodeList childNodes = document2.SelectSingleNode("set").ChildNodes;
            builder.AppendLine("<li " + ((this.price != "") ? "class=\"hoverli\"" : "") + "><strong>价格</strong>");
            builder.AppendLine("<a " + ((this.price == "") ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">不限</a>");
            builder.AppendLine("<a " + ((this.price == (childNodes[0] as XmlElement).GetAttribute("values")) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + "&price=" + (childNodes[0] as XmlElement).GetAttribute("values") + "" + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">" + (childNodes[0] as XmlElement).GetAttribute("title") + "</a>");
            builder.AppendLine("<a " + ((this.price == (childNodes[1] as XmlElement).GetAttribute("values")) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + "&price=" + (childNodes[1] as XmlElement).GetAttribute("values") + "" + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">" + (childNodes[1] as XmlElement).GetAttribute("title") + "</a>");
            builder.AppendLine("<a " + ((this.price == (childNodes[2] as XmlElement).GetAttribute("values")) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + "&price=" + (childNodes[2] as XmlElement).GetAttribute("values") + "" + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">" + (childNodes[2] as XmlElement).GetAttribute("title") + "</a>");
            builder.AppendLine("<a " + ((this.price == (childNodes[3] as XmlElement).GetAttribute("values")) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + "&price=" + (childNodes[3] as XmlElement).GetAttribute("values") + "" + ((this.sort == 0) ? "" : ("&sort=" + this.sort + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">" + (childNodes[3] as XmlElement).GetAttribute("title") + "</a>");
            builder.AppendLine("<a " + ((this.price == (childNodes[4] as XmlElement).GetAttribute("values")) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + "&price=" + (childNodes[4] as XmlElement).GetAttribute("values") + "" + ((this.sort == 0) ? "" : string.Concat(new object[] { "&sort=", this.sort, (this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw)), "" })) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">" + (childNodes[4] as XmlElement).GetAttribute("title") + "</a>");
            builder.AppendLine("</li>");
            builder.AppendLine("<li " + ((this.sort != 0) ? "class=\"hoverli\"" : "") + "><strong>排序</strong>");
            builder.AppendLine("<a " + ((this.sort == 0) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "\">不限</a>");
            builder.AppendLine("<a " + ((this.sort == 1) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "&sort=1\">价格-高到低</a>");
            builder.AppendLine("<a " + ((this.sort == 2) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "&sort=2\">价格-低到高</a>");
            builder.AppendLine("<a " + ((this.sort == 3) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "&sort=3\">评价-高到低</a>");
            builder.AppendLine("<a " + ((this.sort == 4) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "&sort=4\">评价-低到高</a>");
            builder.AppendLine("<a " + ((this.sort == 5) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "&sort=5\">最新</a>");
            builder.AppendLine("<a " + ((this.sort == 6) ? "class=\"hovera\"" : "") + " href=\"?dt=" + this.dt + ((this.cid == 0) ? "" : ("&cid=" + this.cid + "")) + ((this.bid == 0) ? "" : ("&bid=" + this.bid + "")) + ((this.price == "") ? "" : ("&price=" + this.price + "")) + ((this.kw == "") ? "" : ("&kw=" + HttpUtility.UrlEncode(this.kw))) + ((base.Request.QueryString["minDate"] != null) ? ("&minDate=" + base.Request.QueryString["minDate"]) : "") + ((base.Request.QueryString["maxDate"] != null) ? ("&maxDate=" + base.Request.QueryString["maxDate"]) : "") + ((this.goodsNo != "") ? ("&gn=" + this.goodsNo) : "") + "&sort=6\">热销</a>");
            builder.AppendLine("</li>");
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<span class=\"clear\"></span>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder GoodsBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            this.pl.StrWhere = " 1= 1";
            this.pl.StrWhere = this.pl.StrWhere + " and isShelves=1";
            if (base.Request.QueryString["cid"] != null)
            {
                if (base.Request.QueryString["cid"].Length < 36)
                {
                    this.categoryId = BaseFactory.theCategory.GetCategoryIdByCategoryIdentity(Convert.ToInt32(base.Request.QueryString["cid"]));
                }
                else
                {
                    this.categoryId = base.Request.QueryString["cid"];
                }
                this.pl.StrWhere = this.pl.StrWhere +  " and id in(select goods from tbGoodsCategory a left join tbCategory b on a.category=b.categoryIdentity where b.id='" + this.categoryId + "' or b.parentId='" + this.categoryId + "' or parentIdStr like '%" + this.categoryId + "%' group by goods)";
            }


            int iCardtypeId = -1;
            StringBuilder sCardPrices = new StringBuilder();
                if (base.LoginUserMember != null && base.LoginUserMember.DicUserCardList != null && base.LoginUserMember.IsCard)
                {
                    int i = 0;
                    foreach (tbCard o in base.LoginUserMember.DicUserCardList.Values)
                    {
                        if (i == 0)
                        {
                            iCardtypeId = o.cardtypeId;
                            sCardPrices.Append(o.cardprice.ToString());
                        }
                        else
                        {
                            sCardPrices.AppendFormat(",{0}", o.cardprice.ToString());
                        }
                        i++;
                    }

                    this.pl.StrWhere = this.pl.StrWhere + string.Format(" and isProfShelves = 1 and salePrice in ({0}) ", sCardPrices);
                }

      
            if (base.Request.QueryString["dt"] != null)
            {
                this.dt = base.Request.QueryString["dt"];
            }
            if (base.Request.QueryString["p"] != null)
            {
                this.pageIndex = Convert.ToInt32(base.Request.QueryString["p"]);
            }
            if (base.Request.QueryString["bid"] != null)
            {
                this.bid = Convert.ToInt32(base.Request.QueryString["bid"]);
                this.pl.StrWhere = this.pl.StrWhere + ((this.pl.StrWhere == null) ? ("brand=" + this.bid) : (" and brand=" + this.bid));
            }
            if (base.Request.QueryString["price"] != null)
            {
                this.minPrice = Convert.ToDecimal(base.Request.QueryString["price"].Split(new char[] { '-' }).GetValue(0));
                this.maxPrice = Convert.ToDecimal(base.Request.QueryString["price"].Split(new char[] { '-' }).GetValue(1));
                this.pl.StrWhere = this.pl.StrWhere + ((this.pl.StrWhere == null) ? string.Concat(new object[] { "salePrice>=", this.minPrice, " and salePrice<", this.maxPrice }) : string.Concat(new object[] { " and salePrice>=", this.minPrice, " and salePrice<", this.maxPrice }));
            }
            if (base.Request.QueryString["kw"] != null)
            {
                this.kw = base.Request.QueryString["kw"];
                this.pl.StrWhere = this.pl.StrWhere + ((this.pl.StrWhere == null) ? ("goodsName like '%" + this.kw + "%'") : (" and goodsName like '%" + this.kw + "%'"));
            }
            if ((base.Request.QueryString["minDate"] != null) && (base.Request.QueryString["maxDate"] != null))
            {
                this.minDate = Convert.ToDateTime(base.Request.QueryString["minDate"] + " 00:00:00");
                this.maxDate = Convert.ToDateTime(base.Request.QueryString["maxDate"] + " 23:23:59");
                this.pl.StrWhere = this.pl.StrWhere + ((this.pl.StrWhere == null) ? string.Concat(new object[] { "createTime>'", this.minDate, "' and createTime<'", this.maxDate, "'" }) : string.Concat(new object[] { " and createTime>'", this.minDate, "' and createTime<'", this.maxDate, "'" }));
            }
            if (base.Request.QueryString["gn"] != null)
            {
                this.goodsNo = base.Request.QueryString["gn"];
                this.pl.StrWhere = this.pl.StrWhere + ((this.pl.StrWhere == null) ? ("goodsNo like '%" + this.goodsNo + "%'") : (" and goodsNo like '%" + this.goodsNo + "%'"));
            }
            if (base.Request.QueryString["sort"] != null)
            {
                this.sort = Convert.ToInt32(base.Request.QueryString["sort"]);
            }
            this.pl.TblName = "view_googsEntitys";
            this.pl.StrGetFields = "id,goodsNo,goodsName,marketPrice,salePrice,thumbImg,imgAlt,scoreNumber,scores";
            this.pl.PageSize = this.pageSize;
            this.pl.PageIndex = this.pageIndex;
            this.pl.DoCount = 1;
            switch (this.sort)
            {
                case 0:
                    this.pl.FldName = this.order;
                    this.pl.OrderType = this.ot;
                    break;

                case 1:
                    this.pl.FldName = "salePrice";
                    this.pl.OrderType = 1;
                    break;

                case 2:
                    this.pl.FldName = "salePrice";
                    this.pl.OrderType = 0;
                    break;

                case 3:
                    this.pl.FldName = "scores";
                    this.pl.OrderType = 1;
                    break;

                case 4:
                    this.pl.FldName = "scores";
                    this.pl.OrderType = 0;
                    break;

                case 5:
                    this.pl.FldName = "isNew";
                    this.pl.OrderType = 1;
                    break;

                case 6:
                    this.pl.FldName = "isTopSelling";
                    this.pl.OrderType = 1;
                    break;

                default:
                    this.pl.FldName = this.order;
                    this.pl.OrderType = this.ot;
                    break;
            }
            this.total = Convert.ToInt32(BaseFactory.thePageList.GetPageList(this.pl).Rows[0]["Total"]);
            this.pl.DoCount = 0;
            DataTable pageList = BaseFactory.thePageList.GetPageList(this.pl);
            builder.AppendLine("<div " + ((this.dt == "image") ? "class=\"prolist\"" : "class=\"prolist secondlist\"") + ">");
            builder.AppendLine("<ul>");
            foreach (DataRow row in pageList.Rows)
            {
                if (this.dt == "image")
                {
                    builder.AppendLine("<li>");
                    builder.AppendLine(string.Concat(new object[] { "<a href=\"goods.html?id=", row["id"], "\" name=\"#hoverinfo", row["id"], "\" class=\"pro_img\"><img src=\"", row["thumbImg"], "\" alt=\"", row["imgAlt"], "\" /></a>" }));
                    builder.AppendLine(string.Concat(new object[] { "<p><a href=\"goods.html?id=", row["id"], "\" title=\"", row["goodsName"], "\">", (row["goodsName"].ToString().Length > 12) ? (row["goodsName"].ToString().Substring(0, 12) + "...") : row["goodsName"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(row["marketPrice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])), "</strong></em></p>" }));
                    builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", row["id"], "\" style=\"display: none;\"><img src=\"", row["thumbImg"], "\" alt=\"", row["imgAlt"], "\" /><p><strong>", row["goodsName"], "</strong> <span>产品编号：", row["goodsNo"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(row["marketPrice"])), "</del></span></p></div>" }));
                    builder.AppendLine("</li>");
                }
                else if (this.dt == "list")
                {
                    builder.AppendLine("<li>");
                    builder.AppendLine(string.Concat(new object[] { "<a href=\"goods.html?id=", row["id"], "\"><img src=\"", row["thumbImg"], "\" alt=\"", row["imgAlt"], "\" /></a>" }));
                    builder.AppendLine(string.Concat(new object[] { "<div><h6><a href=\"goods.html?id=", row["id"], "\" title=\"", row["goodsName"], "\">", (row["goodsName"].ToString().Length > 20) ? (row["goodsName"].ToString().Substring(0, 20) + "...") : row["goodsName"], "</a></h6>" }));
                    DataTable table2 = BaseFactory.theGoodsAttribute.FrontDeskGetGoodsAttributeByGoodAndTop(Convert.ToInt32(row["id"]), 5);
                    foreach (DataRow row2 in table2.Rows)
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p><strong>", row2["attributeName"], "：</strong> ", row2["inputValue"], "</p>" }));
                    }
                    builder.AppendLine("</div>");
                    builder.AppendLine("<div class=\"lastspan\"><p>市场价" + string.Format("{0:C}", Convert.ToDecimal(row["marketPrice"])) + "</p><p>会员价：<strong>" + string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])) + "</strong></p>");
                    if (!Convert.IsDBNull(row["scores"]))
                    {
                        double num = Convert.ToDouble(row["scores"]);
                        if ((num < 1.5) && (num >= 1.0))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star01.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 2.0) && (num >= 1.5))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star015.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 2.5) && (num >= 2.0))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star02.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 3.0) && (num >= 2.5))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star025.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 3.5) && (num >= 3.0))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star03.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 4.0) && (num >= 3.5))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star035.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 4.5) && (num >= 4.0))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star04.gif\" alt=\"\" /></p>");
                        }
                        else if ((num < 5.0) && (num >= 4.5))
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star045.gif\" alt=\"\" /></p>");
                        }
                        else if (num == 5.0)
                        {
                            builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star05.gif\" alt=\"\" /></p>");
                        }
                    }
                    else
                    {
                        builder.AppendLine("<p>综合评分</p><p><img src=\"/script/images/star00.gif\" alt=\"\" /></p>");
                    }
                    builder.AppendLine(string.Concat(new object[] { "<p>已有", row["scoreNumber"], "人评分 <input type=\"button\" value=\"查看详情\" onclick=\"window.location='goods.html?id=", row["id"], "';\" /></p></div>" }));
                    builder.AppendLine("<span class=\"clear\"></span>");
                    builder.AppendLine("</li>");
                }
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine(new PageListNo().FrontDeskDisplayPage(this.total, this.pageSize, this.pageIndex).ToString());
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected StringBuilder TopSellingBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            //builder.AppendLine("<div class=\"sidebar\">");
            //builder.AppendLine("<div class=\"sidelist\">");
            builder.AppendLine("<h6><strong>热销推荐</strong></h6>");
            builder.AppendLine("<ul>");
            DataTable table = BaseFactory.theGoods.GetGoodsByIsTopSellingAndIsShelvesAndTop(1, 1, 5);
            foreach (DataRow row in table.Rows)
            {
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<a href=\"goods.html?id=", row["id"], "\"><img src=\"", row["thumbImg"], "\" alt=\"", row["imgAlt"], "\" /></a>" }));
                builder.AppendLine(string.Concat(new object[] { "<p><a href=\"goods.html?id=", row["id"], "\" title=\"", row["goodsName"], "\">", row["goodsName"], "</a><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])), "</strong></em><span>已有<strong>", row["scoreNumber"], "</strong>人评分</span></p>" }));
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("</div>");
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.xmlPath));
            XmlNodeList childNodes = document.SelectSingleNode("goods_list_ad/right").ChildNodes;
            foreach (XmlNode node in childNodes)
            {
                XmlElement element = (XmlElement)node;
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
            }
            builder.AppendLine("</div>");
        
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder BindLeftMenu()
    {
        StringBuilder builder = new StringBuilder();
        DataTable dtCatagory;
        tbCategory oCatetory;
        string cid = base.Request.QueryString["cid"];
        if (Request.QueryString["pid"] == null)
        {
            cid = base.Request.QueryString["cid"];
        }
        else
        {
            cid = base.Request.QueryString["pid"];
        }
        if (cid == null) cid = "00000000-0000-0000-0000-000000000000";
        if (cid.Length < 36)
        {
            dtCatagory = BaseFactory.theCategory.GetCategoryListByCategoryIdentity(int.Parse(cid));
            if (dtCatagory != null )
            {
                foreach (DataRow dr in dtCatagory.Rows)
                {
                    if (dr["depth"].ToString() == "0")
                    {
                        cid = dr["id"].ToString();
                        break;
                    }   
                }
             }
         
        }
        oCatetory = BaseFactory.theCategory.GetModel(cid);
        builder.AppendLine(" <div class=\"w1190\">");
        builder.AppendLine("<div class=\"navBar\">");
        builder.AppendLine("<div class=\"navBar\">");

        if (oCatetory == null)
        {
           builder.AppendLine("<div class=\"barTitle pl10\">全部商品分类</div>");
        }
        else
        {
            builder.AppendLine("<div class=\"barTitle pl10\">" + oCatetory.categoryName + "</div>");
        }
        DataTable table = BaseFactory.theCategory.GetCategoryByParentIdAndCompanyIdAndIsShow(cid, base.CompanyId, 1);
        builder.AppendLine("<div class=\"navBarCon mb10\" id=\"navBarConIndex\">");
        foreach (DataRow row in table.Rows)
        {
            builder.AppendLine("<dl class=\"pl10\">");
            DataTable table1 = BaseFactory.theCategory.GetCategoryByParentIdAndCompanyIdAndIsShow(row["id"].ToString(), base.CompanyId, 1);
            bool isExpand = false;
            if (Request.QueryString["cid"] == row["categoryIdentity"].ToString())
            {
                isExpand = true;
            }
            if (table1 != null)
            {
                foreach (DataRow subRow in table1.Rows)
                {
                    if (subRow["categoryIdentity"].ToString() == Request.QueryString["cid"])
                    {
                        isExpand = true;
                        break;
                    }
                }
            }

            if (isExpand)
            {
                builder.AppendFormat("<dt class=\"thirdBg pl10 foc\"><a href=\"goods_list.html?cid={0}\" target=\"_self\" >{1}</a></dt>", row["categoryIdentity"], row["categoryName"]);
                builder.AppendLine("<dd class=\"pl10 foc\">");
            }
            else
            {
                   builder.AppendFormat("<dt class=\"thirdBg pl10\"><a href=\"goods_list.html?cid={0}\" target=\"_self\" >{1}</a></dt>", row["categoryIdentity"], row["categoryName"]);
                builder.AppendLine("<dd class=\"pl10\">");
            }

          
            DataTable subTable;
            if (table1 != null)
            {
                foreach (DataRow subRow in table1.Rows)
                {
                    subTable = BaseFactory.theCategory.GetCategoryByParentIdAndCompanyIdAndIsShow(subRow["id"].ToString(), base.CompanyId, 1);
                    if (subTable == null || subTable.Rows.Count <= 0)
                    {
                        builder.AppendFormat("<span><a  href=\"goods_list.html?cid={0}&pid={2}\" target=\"_self\"  >{1}</a></span>"
                                       , subRow["categoryIdentity"]
                                       , subRow["categoryName"]
                                         , row["categoryIdentity"]
                                       );
                    }
                    else
                    {
                        builder.AppendFormat("<span><a  href=\"goods_list.html?cid={0}\" target=\"_blank\" >{1}</a></span>"
                                             , subRow["categoryIdentity"]
                                             , subRow["categoryName"]
                                             );
                    }
                }
            }
            builder.AppendLine("</dd>");
            builder.AppendLine("</dl>"); 
        }
        builder.AppendLine("</div>");
        builder.AppendLine("</div>");
        builder.AppendLine("</div>");
        builder.AppendLine("</div>");
        return builder;
    }
}